#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > choles_cc2_polar.info <<'%EOF%'
   choles_cc2_polar
   ----------------
   Molecule:         Benzene in D2h
   Wave Functions:   Cholesky CC2 / aug-cc-pVDZ
   Test Purpose:     Frequency-dependent polarizabilities
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > choles_cc2_polar.mol <<'%EOF%'
BASIS
aug-cc-pVDZ
6 - annulene. avdz basis
B3LYP/631-G* geometry from Wannere et. al
    2  0           a  0.10E-14
        6.    6 
C1    0.000000     1.394541     0.000000
C2    0.000000     0.697270     1.207708
C3    0.000000    -0.697270     1.207708
C4    0.000000    -1.394541     0.000000
C5    0.000000    -0.697270    -1.207708
C6    0.000000     0.697270    -1.207708
        1.    6
H1    0.000000     2.478907     0.000000
H2    0.000000     1.239453     2.146796
H3    0.000000    -1.239454     2.146796
H4    0.000000    -2.478907     0.000000
H5    0.000000    -1.239453    -2.146796
H6    0.000000     1.239454    -2.146796
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > choles_cc2_polar.dal <<'%EOF%'
**DALTON
.RUN WAVE
.CHOLES
**INTEGRALS
.DIPLEN
**CHOLESKY
.REDUCE
.SPANDI
  1.0d-3
.THRCOM
 1.0D-8
**WAVE FUNCTION
.CC
*SCF INPUT
.THRESH
 1.0D-8
.MAX DIIS
  100
*ORBITAL
.MOSTART
 HUCKEL
*CC INP
.FREEZE
  6   0
.CC2
*CCLR
.DIPOLE
.FREQUE
  2
  0.0   0.07723
.AVERAGE
ALPHA_ANI
XYDEGN
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >choles_cc2_polar.check
cat >>choles_cc2_polar.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CC2 energies:
CRIT1=`$GREP "Final * HF energy:"  $log | $GREP "\-230.7281544." | wc -l`
CRIT2=`$GREP "Coupled cluster MP2" $log | $GREP "\-231.53883(40|39)" | wc -l`
CRIT3=`$GREP "Total CC2 * energy:     *           -231.5458137" $log | wc -l`
TESTA=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRLA=4
ERRORA="ENERGIES NOT CORRECT"



# CC2 polarizabilities
CRIT1=`$GREP "alpha_iso" $log | $GREP "\-*0*\.0000 * 0*\.0000 * 71.680" | wc -l`
CRIT2=`$GREP "alpha_ani" $log | $GREP "\-*0*\.0000 * 0*\.0000 * 38.577" | wc -l`
CRIT3=`$GREP "\-0*\.0772 * 0*\.0772 * 74.6223" $log | wc -l`
CRIT4=`$GREP "\-0*\.0772 * 0*\.0772 * 41.1364" $log | wc -l`
TESTB=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRLB=4
ERRORB="CC2 POLARIZABILITIES NOT CORRECT"


TESTSUM=`expr $TESTA \+ $TESTB`
CTRLSUM=`expr $CTRLA \+ $CTRLB`

if [ $TESTSUM -eq $CTRLSUM ]
then
  echo TEST ENDED PROPERLY
else

  if [ $TESTA -ne $CTRLA ]; then
    echo "$ERRORA ( test = $TESTA; control = $CTRLA ); "
  fi

  if [ $TESTB -ne $CTRLB ]; then
    echo "$ERRORB ( test = $TESTB; control = $CTRLB ); "
  fi

  echo THERE IS A PROBLEM 
  exit 1

fi

exit 0

%EOF%
chmod +x choles_cc2_polar.check
#######################################################################
